//getOneAdmin();

function getOneAdmin() {
 
	//获取个人信息
	$.ajax({
		url: urlcore + "/api/user/getadmin",
		type: "get",
		dataType: 'json',
		async: false,
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
 
				var userName = data.data.userName;
				//var userid = data.data.id;
				var headimg = data.data.headImg;
				
				sessionStorage.setItem("userName");
			  sessionStorage.setItem("headImg");

			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			}
			/*else if(data.code == 'PARAMETER_INVALID') {
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}
			}*/
			else {
				alert(data.msg);
			}

		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
}



//广告
//selectMessageList();
/*function selectMessageList(){
	   
	    $.ajax({
        url: urlcore+"/api/message/selectMessageList?type=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {}
				});
		/*console.log(goodslist);
			},
			error: function() {
				alert("error");
			}
		});
}
*/

var currentPage1 = 1;
var currentPage2 = 1;
var currentPage3 = 1;
var currentPage4 = 1;
var currentPage5 = 1;
var currentPage6 = 1;
var ss6 = 0;

function selectGoodsList26() {
	if(currentPage6 == 0 || currentPage6 == 1 || currentPage6 == 2 || ss6 != 0) {

		$("#goodslist").html("");
		$("#goodslist2").html("");
		$("#goodslist3").html("");
		$("#goodslist4").html("");
		$("#goodslist5").html("");
		ss = 0;
		ss2 = 0;
		ss3 = 0;
		ss4 = 0;
		ss5 = 0;
		currentPage1 = 1;
		currentPage2 = 1;
		currentPage3 = 1;
		currentPage4 = 1;
		currentPage5 = 1;
		$.ajax({ //	url: urlcore + "/api/goods/selectGoodsList22?current=" + currentPage6 + "&priceLevel=3",
			url: urlcore + "/api/goods/selectGoodsList2?current=" + currentPage6 + "&sort=3&status=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
			    console.log(data)
				if(data.success == true) {
					var goodslist = "";
					ss6 = data.data.goodsPage.records.length;
					$.each(data.data.eachPictureList, function(q, m) {
						if(q == svn) {
							if(m.auctionType == 1) {
								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img style="width: 100%;height: 130px;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
							} else if(m.auctionType == 2) {
								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img style="width: 100%;height: 130px;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
							}/*  else if(m.auctionType == 3) {
								goodslist += '<a href="' + m.auctionHttpUrl + '"><img style="width: 100%;height: 130px;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
							} */

						}
					});
					$.each(data.data.goodsPage.records, function(y, n) {
						goodslist += '<div class="public_goods" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img onerror="errorImg(this)"  src="' + n.coverUrl + '" />' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							                           
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';

					});
					$("#goodslist6").append(goodslist);
				}
				/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
	}
}

var ss5 = 0;

function selectGoodsList25() {
	if(currentPage5 == 1 || currentPage5 == 2 || currentPage5 == 3 || ss5 != 0) {
		$("#goodslist").html("");
		$("#goodslist2").html("");
		$("#goodslist3").html("");
		$("#goodslist4").html("");
		$("#goodslist6").html("");
		ss = 0;
		ss2 = 0;
		ss3 = 0;
		ss4 = 0;
		ss6 = 0;
		currentPage1 = 1;
		currentPage2 = 1;
		currentPage3 = 1;
		currentPage4 = 1;
		currentPage6 = 1;
		$.ajax({
			url: urlcore + "/api/goods/selectGoodsList2?current=" + currentPage5 + "&goodsType=5&sort=3&status=1", // "&priceLevel=2",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var goodslist = "";
					ss5 = data.data.goodsPage.records.length;
					$.each(data.data.eachPictureList, function(q, m) {
						if(q == svn) {
							if(m.auctionType == 1) {
								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} else if(m.auctionType == 2) {
								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							}/*  else if(m.auctionType == 3) {
								goodslist += '<a href="' + m.auctionHttpUrl + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} */

						}

					});
					$.each(data.data.goodsPage.records, function(y, n) {
						goodslist += '<div class="public_goods" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img onerror="errorImg(this)"  src="' + n.coverUrl + '" />' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';

					});
					$("#goodslist5").append(goodslist);
				}
				/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
	}
}

var ss4 = 0;

function selectGoodsList24() {
	if(currentPage4 == 1 || currentPage4 == 2 || ss4 != 0 || currentPage4 == 0) {
		$("#goodslist").html("");
		$("#goodslist2").html("");
		$("#goodslist3").html("");
		$("#goodslist5").html("");
		$("#goodslist6").html("");
		ss = 0;
		ss2 = 0;
		ss3 = 0;
		ss5 = 0;
		ss6 = 0;
		currentPage1 = 1;
		currentPage2 = 1;
		currentPage3 = 1;
		currentPage5 = 1;
		currentPage6 = 1;
		$.ajax({
			url: urlcore + "/api/goods/selectGoodsList2?current=" + currentPage4 + "&sort=4&status=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var goodslist = "";
					ss4 = data.data.goodsPage.records.length;
					$.each(data.data.eachPictureList, function(q, m) {
						if(q == svn) {
							if(m.auctionType == 1) {
								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} else if(m.auctionType == 2) {
								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} /* else if(m.auctionType == 3) {
								goodslist += '<a href="' + m.auctionHttpUrl + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;"  src="' + m.imgUrl + '"></a>';
							} */

						}

					});
					$.each(data.data.goodsPage.records, function(y, n) {
						goodslist += '<div class="public_goods" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img onerror="errorImg(this)"  src="' + n.coverUrl + '" />' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';

					});
					$("#goodslist4").append(goodslist);
				}
				/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
	}
}

var ss3 = 0;

function selectGoodsList23() {
	if(currentPage3 == 1 || currentPage3 == 2 || ss3 != 0 || currentPage3 == 0) {
		$("#goodslist").html("");
		$("#goodslist2").html("");
		$("#goodslist4").html("");
		$("#goodslist5").html("");
		$("#goodslist6").html("");
		ss = 0;
		ss2 = 0;
		ss4 = 0;
		ss5 = 0;
		ss6 = 0;
		currentPage1 = 1;
		currentPage2 = 1;
		currentPage4 = 1;
		currentPage5 = 1;
		currentPage6 = 1;
		$.ajax({
			url: urlcore + "/api/goods/selectIndexGoodsList?current=" + currentPage2 + "&goodsType=2&sort=2",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					// console.log(data)
					var goodslist = "";
					ss3 = data.data.list.length;
					$.each(data.data.eachPictureList, function(q, m) {
						if(q == svn) {
							if(m.auctionType == 1) {
								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%; src="' + m.imgUrl + '"></a>';
							} else if(m.auctionType == 2) {
								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%; src="' + m.imgUrl + '"></a>';
							} /* else if(m.auctionType == 3) {
								goodslist += '<a href="' + m.auctionHttpUrl + '"><img  onerror="errorImg(this)" style="width: 100%; src="' + m.imgUrl + '"></a>';
							} */

						}

					});
					$.each(data.data.list, function(y, n) {
						goodslist += '<div class="public_goods" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img  onerror="errorImg(this)"  src="' +n.coverUrl+ '" />' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';

					});
					$("#goodslist3").append(goodslist);
				}
				/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
	}
}

var ss2 = 0;

function selectGoodsList22() {
	if(ss2 != 0 || currentPage2 == 1 || currentPage2 == 2 || currentPage2 == 0) {

		$("#goodslist").html("");
		$("#goodslist3").html("");
		$("#goodslist4").html("");
		$("#goodslist5").html("");
		$("#goodslist6").html("");
		ss = 0;
		ss3 = 0;
		ss4 = 0;
		ss5 = 0;
		ss6 = 0;
		currentPage1 = 1;
		currentPage3 = 1;
		currentPage4 = 1;
		currentPage5 = 1;
		currentPage6 = 1;
		$.ajax({ //"/api/goods/selectGoodsList22?current=" + currentPage2 + "&goodsType=2",
			url: urlcore + "/api/goods/selectIndexGoodsList?current=" + currentPage2 + "&goodsType=2&sort=2",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					
					var goodslist = "";
					ss2= data.data.list.length;

					// ss2 = data.data.list.length;
					$.each(data.data.eachPictureList, function(q, m) {
						if(q == svn) {
							if(m.auctionType == 1) {
								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} else if(m.auctionType == 2) {
								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							}/*  else if(m.auctionType == 3) {
								goodslist += '<a href="' + m.auctionHttpUrl + '"><img onerror="errorImg(this)" style="width: 100%;height: 130px;" src="' + m.imgUrl + '"></a>';
							} */

						}

					});
					$.each(data.data.list, function(y, n) {
						goodslist += '<div class="public_goods" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img onerror="errorImg(this)"  src="' + n.coverUrl + '" />' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';

					});
					$("#goodslist2").append(goodslist);
				}
				/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
	}
}

var ss = 0;
var svn = 0;
var  tabs= [
     {id: "nav_1",isSelect: true,title: "推荐",value:1,isFirst: false},
     {id: "nav_2",isSelect: false,title: "上新",value: 2,isFirst: true},
{
	id: "nav_3",
	isSelect: false,
	title: "关注",
	value: 3,
	isFirst: true
},
{
	id: "nav_4",
	isSelect: false,
	title: "低价",
	value: 4,
	isFirst: true
},
{
	id: "nav_5",
	isSelect: false,
	title: "中等",
	value: 5,
	isFirst: true
},
{
	id: "nav_6",
	isSelect: false,
	title: "高档",
	value: 6,
	isFirst: true
}
]
  var curTabId= "nav_1";//当前tabid
  // var isShowFloatTab= false, //是否显示悬浮tab

  var guessLikeList= []; //推荐猜你喜欢列表
  var  guessLikeLenght= 1;
  var  guessCurrent= 1;
  var  guessHasNextPage= true;

  var  newsList= [];//上新列表
  var  newslength= 1;
  var  newsCurrent= 1;
  var  newsHasNextPage= true;

  var  hotList= []; //热卖
  var  hotLength= 1;
  var  hotCurrent= 1;
  var  hotHasNextPage= true;

  var  lowList= []; //低价排序
  var lowLength= 1;
  var  lowCurrent= 1;
  var lowHasNextPage= true;

  var  modList= []; //中等排序
  var  modLength= 1;
  var  modCurrent= 1;
  var  modHasNextPage= true;

  var  highList= []; //高价
  var  highLength=1;
  var  highCurrent= 1;
  var  highHasNextPage= true;
 function getShopGoods() {
	 var that=this;
    var nowTab = 1;
    for (let obj of that.tabs) {
      if (obj.isSelect) {
        nowTab = obj.value;
      }
    }

    var shopId = that.shopId;
    var goodsType = '';
    var sort = '';
    var current = 1;

    //推荐
    if (nowTab == 1) {
      goodsType = 1;
      sort = 2;
      current = that.guessCurrent
    }
    //上新
    if (nowTab == 2) {
      goodsType = 2;
      sort = 2;
      current = that.newsCurrent
    }
    //关注
    if (nowTab == 3) {
      goodsType = '';
      sort = 7;
      current = that.hotCurrent
    }
    //低价
    if (nowTab == 4) {
      goodsType = '';
      sort = 4;
      current = that.lowCurrent
    }
    //中等
    if (nowTab == 5) {
      goodsType = '';
      sort = 8;
      current = that.modCurrent
    }
    //高档
    if (nowTab == 6) {
      goodsType = '';
      sort = 3;
      current = that.highCurrent
    }
     $.ajax({
     	url: urlcore + '/api/goods/selectIndexGoodsList?goodsType=' + goodsType + "&sort=" + sort + "&current=" + current, //selectGoodsList2?current=" + currentPage1 + "&goodsType=1&sort=2&status=1
     	type: "get",
     	dataType: 'json',
     	contentType: "application/json;charset=utf-8",
     	success: function(json) {
				if (json.data && json.success) {
					//推荐
					if (nowTab == 1) {
						    guessLikeList=that.guessLikeList.concat(json.data.list),
							  guessLikeLenght=json.data.total,
							  guessCurrent= json.data.pageNum,
							  guessHasNextPage= json.data.hasNextPage
           }
					//上新
					if (nowTab == 2) {
					
							newsList=that.guessLikeList.concat(json.data.list),
							newsLength= json.data.total,
							newsCurrent= json.data.pageNum,
							newsHasNextPage= json.data.hasNextPage
						
					}
 					//关注
					if (nowTab == 3) {
	           
							hotList= that.hotList.concat(json.data.list),
							hotLength= json.data.total,
							hotCurrent= json.data.pageNum,
							hotHasNextPage= json.data.hasNextPage;
						
					}
				//低价
					if (nowTab == 4) {
						
							lowList= that.lowList.concat(json.data.list),
							lowLength= json.data.total,
							lowCurrent= json.data.pageNum,
							lowHasNextPage= json.data.hasNextPage
						
					}
					//中等
					if (nowTab == 5) {
				
							modList= that.modList.concat(json.data.list),
							modLength= json.data.total,
							modCurrent= json.data.pageNum,
							modHasNextPage= json.data.hasNextPage
						
					}
					//高档
					if (nowTab == 6) {
						
							highList= that.highList.concat(json.data.list),
							highLength= json.data.total,
							highCurrent= json.data.pageNum,
							highHasNextPage=json.data.hasNextPage
					
					}
				} else {
					console.log("请求失败")
				}
 			 }
			})
  }
	//刷新 
	function goodPullDown() {
    var that = this;
    var nowTab = 1;
    for (let obj of that.tabs) {
      if (obj.isSelect) {
        nowTab = obj.value
      }
    }
    //推荐
    if (nowTab == 1) {
      if (that.guessHasNextPage) {
        // that.setData({
          guessCurrent= that.guessCurrent + 1
        // })
        getShopGoods()
      }
    }
    //上新
    if (nowTab == 2) {
      if (that.newsHasNextPage) {
        
          var newsCurrent= that.newsCurrent + 1
       
        // getShopGoods()
      }
    }
    //关注
    if (nowTab == 3) {
      if (that.hotHasNextPage) {
      
       var   hotCurrent= that.hotCurrent + 1
       
        // getShopGoods()
      }
    }
    //低价
    if (nowTab == 4) {
      if (that.lowHasNextPage) {
         
          lowCurrent= that.lowCurrent + 1
       
        // getShopGoods()
      }
    }
    //中等
    if (nowTab == 5) {
      if (that.modHasNextPage) {
        
          modCurrent= that.modCurrent + 1
//        
//         getShopGoods()
      }
    }
    //高价
    if (nowTab == 6) {
      if (that.highHasNextPage) {
        
          highCurrent= that.highCurrent + 1
       
        // getShopGoods()
      }
    }
  }
getShopGoods();
goodPullDown() ;

function selectGoodsList21() {
	if(ss != 0 || currentPage1 == 1 || currentPage1 == 0) {
		$("#goodslist2").html("");
		$("#goodslist3").html("");
		$("#goodslist4").html("");
		$("#goodslist5").html("");
		$("#goodslist6").html("");
		currentPage2 = 1;
		currentPage3 = 0;
		currentPage4 = 1;
		currentPage5 = 1;
		currentPage6 = 1;
		console.log(currentPage1)
		$.ajax({
			url: urlcore + "/api/goods/selectIndexGoodsList?current=" + currentPage1 + "&goodsType=1&sort=2", //selectGoodsList2?current=" + currentPage1 + "&goodsType=1&sort=2&status=1
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				
				if(data.success == true) {
					ss = data.data.list.length;
					var goodslist = "";
// 					$.each(data.data.list, function(q, m) {
// 						if(q == svn) {
// 							if(m.auctionType == 1) {
// 								goodslist += '<a href="6.0.0dianpu.html?id=' + m.auctionId + '"><img style="width: 100%;height: 100%;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
// 							} else if(m.auctionType == 2) {
// 								goodslist += '<a href="7.0.0goods_detail.html?id=' + m.auctionId + '"><img style="width: 100%;height:100%;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
// 							} else if(m.auctionType == 3) {
// 								goodslist += '<a href="' + m.auctionHttpUrl + '"><img style="width: 100%;height: 100%;height:100%;" onerror="errorImg(this)" src="' + m.imgUrl + '"></a>';
// 							}
// 
// 						}
// 
// 					});
					$.each(data.data.list, function(y, n) {
						goodslist += '<div class="public_goods .box-item" >' +
							'				<a href="7.0.0goods_detail.html?id=' + n.id + '">' +
							'					<dl>' +
							'						<dt>' +
							'							<img onerror="errorImg(this)" src="' + n.coverUrl + '" height:50% width:50%/>' +
							'						</dt>' +
							'						<dd>' +
							'							<h5>' + n.goodsTitle + '</h5>' +
							'							<h6>&yen;' + n.packPrice + ' <span style="display:inline_inblock;font-size:9px;color:#ccc;text-decoration:line-through">&yen;' + n.tradePrice + '</span></h6>' +
							'						</dd>' +
							'					</dl>' +
							'				</a>' +
							'			</div>';
            });
					svn++;
					$("#goodslist").append(goodslist);
					
				}
			
			},
			error: function() {
				alert("error");
			}
		});
	}
}
var index=$('#goodslist');
 var boxArr = $('.public_goods'),
 
	num = Math.floor(index.clientWidth / boxArr.eq(0).outerWidth(true)),

	columnHeightArr = [];
	console.log(num)
 // columnHeightArr.length = num;
 arrangement();
　　  $('.public_goods').css('minHeight',Math.max.apply(null, columnHeightArr));
    lazyLoad();
    function arrangement() {
        boxArr.each(function(index, item) {
            if (index < num) {
                columnHeightArr[index] = $(item).position().top + $(item).outerHeight(true);
            } else {
                var minHeight = Math.min.apply(null, columnHeightArr),
                    minHeightIndex = $.inArray(minHeight, columnHeightArr);
                $(item).css({
                    position: 'absolute',
                    top: minHeight,
                    left: boxArr.eq(minHeightIndex).position().left
                });
                columnHeightArr[minHeightIndex] += $(item).outerHeight(true);
            }
        });
    }

    function lazyLoad() {
        var boxArr = $('.box-item');
        boxArr.each(function(index, item) {
            var viewTop = $(item).offset().top - $(window).scrollTop(),
                imgObj = $(item).find('.img');
            if ((viewTop < $(window).height()) && ($(item).offset().top + $(item).outerHeight(true) > $(window).scrollTop())) {
                imgObj.css('backgroundImage','url('+imgObj.attr("data-src")+')').removeClass('data-src');
                $(item).removeClass('box-item');
            }
        })
    }

    function cRate(obj) {
        return obj.height / obj.width;
    }

    function scrollLoad() {
        var viewHeight = $(window).scrollTop() + $(window).height(),
            minHeight = Math.min.apply(null, columnHeightArr);
//         if (viewHeight >= minHeight) {
//             //loadMore...
//         }
    }

    $(window).scroll(function() {
        lazyLoad();
        scrollLoad();
    });
//logout();
function logout() {
	$.ajax({
		url: urlcore + "/api/login/logout",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {},
		error: function() {
			alert("error");
		}
	});
}

//限时抢购的时间
//xianshu();
/*function xianshu() {

	$.ajax({
		url: urlcore + "/api/rushGoods/selectRushGoodsList?current=1&type=1&timestatus=1",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {}
		},
		error: function() {
			alert("error");
		}
	});
}
*/

function quhoutai() {
	var code = getvl("code");
	if(code == "") {
		//window.location.href="gotoindex.html?types=y";
	} else {
		$.ajax({
			url: urlcore + "/api/user/getOpenid?code=" + code,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				//   alert("...."+ JSON.stringify(data.data));
				if(data.success == true) {
					var uuid = data.data.id;
					if(data.data.password != null && data.data.password != "" && data.data.phone != null && data.data.phone != "") {
						toLogin(data.data.phone, data.data.password);
					} else {
						//window.location.href="../wx/1.3.0zhuce.html?uid="+uuid;
					}
				} else {
					//alert('返回错误');
				}
			},
			error: function() {
				alert("error");
			}
		});

	}

}

function toLogin(phone, password) {
	if(phone != "" && password != "") {
		$.ajax({
			url: urlcore + "/api/login/loginPhoneweixin",
			type: "POST",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			data: JSON.stringify({
				phone: phone,
				password: password
			}),
			success: function(da) {
				if(da.success == true) {
					/*	console.log(da.data.id);
                   console.log(da.data);
                   	console.log(da.data.id);*/
					//设置cookie
					var domain_url = urlcore.split('://')[1];
					if(domain_url.indexOf(':') > -1) {
						domain_url = domain_url.split(':')[0];
					} else {
						domain_url = domain_url.split('/')[0];
					}
					document.cookie = "sid=" + da.data.token + ";path=/;domain=" + domain_url;
					// alert(document.cookie);
					//window.location.href = "index.html";
				} else {
					alert(da.msg);
				}
			},
			error: function() {
				/* Act on the event */
				alert("error");
			}
		});
	}
}
//点击发布 
function goclicked1(){
	
	if(!alert('需要您登陆才能继续')){
		window.location.href = "1.0.0denglu.html";
		if(tpken){
				window.location.href = "4.2.7qiugou_fabu.html";
		}
	}
	
// 	window.location.href = "4.2.7qiugou_fabu.html";
// 	var tpken=sessionStorage.getItem('ryToken');
// 	if(tpken){
// 		window.location.href = "4.2.7qiugou_fabu.html";
// 	}

	// var status=false;
// 	console.log(phone)
// 	var phone=sessionStorage.getItem('phone')
// 	if(phone == '') {
// 		layer.alert("请输入手机号码！");
// 		return false;
// 	}
// 	var password = $('#phossne').val().trim();
// 	var pasword=sessionStorage.getItem('password')
// 	if(password == '') {
// 		layer.alert("请输入登录密码！");
// 		return false;
// 	}
// 	$.ajax({
// 		url: urlcore + "/api/user/loginByPhone",
// 		type: "post",
// 		contentType: "application/json;charset=utf-8",
// 		data: JSON.stringify({
// 			"phone": phone,
// 			"password": password
// 		}),
// 		dataType: "json",
// 		success: function(data) {
// 			   sessionStorage.setItem('userIdd',data.data.id);
// 					if(data.success == true) {
// 						if(layer.confirm('登录成功')) {
// 							getUserInfoByUserId();
// 							var da = data.data; 
// 							if(window.sessionStorage) {
// 								//设置cookie
// 								var domain_url = urlcore.split('://')[1];
// 								if(domain_url.indexOf(':') > -1) {
// 									domain_url = domain_url.split(':')[0];
// 								} else {
// 									domain_url = domain_url.split('/')[0];
// 								}
// 								document.cookie = "JSESSIONID=" + data.data.token + ";path=/;domain=" + domain_url;
// 								window.location.href ="4.2.7qiugou_fabu.html";
// 								
// 							} else {
// 								alert("浏览暂不支持sessionStorage");
// 							}
// 						} else {
// 							//跳转列表页
// 							window.location.href = "4.";
// 						}
// 					} else if(data.code == 'OVERTIME') {
// 						var thisUrl = window.location.href;
// 						if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
// 							top.window.location.href = "1.0.0denglu.html";
// 						}
// 					} else {
// 						alert(data.msg);
// 					}
// 		},
// 		error: function() {
// 			alert("error");
// 		}
// 				
// 	});
}
